package Exists;

import java.text.Collator;
import java.util.Comparator;
import java.util.Iterator;
import java.util.Locale;
import java.util.TreeSet;

public class TreeSetScore {

    public static void main(String[] args) {
        TreeSet<Student> res = new TreeSet<>(new Comparator<Student>() {
            @Override
            public int compare(Student o1, Student o2) {


                int score = ((o1.chinesescore+o1.Englishscore+o1.Mathsocer)-(o2.chinesescore+o2.Englishscore+o2.Mathsocer));

                score = score == 0 ? o1.Mathsocer-o2.Mathsocer:score;
                score = score == 0 ? o1.Englishscore - o2.Englishscore:score;

                Collator   num = Collator.getInstance(Locale.CHINA);
                  score = score ==0?  num.compare(o1.getName(),o2.getName()):score;
                return score;
            }
        });

        res.add(new Student("张三",98,99,89));
        res.add(new Student("王二",96,98,99));
        res.add(new Student("大马哈",95,99,89));
        res.add(new Student("李子健",94,99,100));
        res.add(new Student("周世宗",95,92,88));
        res.add(new Student("阿伟世一",95,92,88));
        res.add(new Student("赵又廷",95,92,88));
        res.add(new Student("正阳",95,92,88));



        Iterator<Student> iterator = res.iterator();

        while (iterator.hasNext()){


            System.out.println(iterator.next());
        }



    }

    }

